package com.onenine.chat.model;


import com.onenine.app.response.UserInfoResponse;
import com.onenine.chat.commons.IUser;
import com.onenine.chat.rongcloud.RcUser;

import org.litepal.crud.DataSupport;

/**
 * 本地用户
 */
public class LUser extends DataSupport implements IUser {

    private String userId;
    private String nickName;
    private String photo;

    public LUser() {
    }

    public LUser(String id, String nickName, String photo) {
        this.userId = id;
        this.nickName = nickName;
        this.photo = photo;
    }

    public LUser(RcUser rcUser) {
        this.userId = rcUser.getUserId();
        UserInfoResponse userInfo = RcUser.getInstance().getInfoResponse();
        if (userInfo != null) {
            this.nickName = userInfo.getNickName();
            this.photo = userInfo.getPhoto();
        }
    }

    @Override
    public String getUserId() {
        return userId == null ? "" : userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    @Override
    public String getNickName() {
        return nickName == null ? "" : nickName;
    }

    public void setNickName(String nickName) {
        this.nickName = nickName;
    }

    @Override
    public String getPhoto() {
        return photo == null ? "" : photo;
    }

    public void setPhoto(String photo) {
        this.photo = photo;
    }

    @Override
    public String toString() {
        return "LUser{" +
                "userId='" + userId + '\'' +
                ", nickName='" + nickName + '\'' +
                ", photo='" + photo + '\'' +
                '}';
    }
}
